/*
 * @Author: CC-TSR
 * @Date: 2021-01-08 08:57:20
 * @LastEditTime: 2021-01-21 13:21:25
 * @LastEditors: xiejiancheng1999@qq.com
 * @Description: 
 * @FilePath: \前端\src\store\modules\oneMap.js
 * @可以输入预定的版权声明、个性签名、空行等
 */
const state = {
  map: null,
  view: null,
  layers: [],
  isLegendShow: false,
  isShowXzq: false,
  isShowAnalystTool: false,
  treeData: [],
  initLayers: null,
  userServiceId: null,
  userServices: null,
  siderPanel: 'layerTree',
};

const mutations = {
  updateMapsMutation(state, payload) {
    state.map = payload.map;
    state.view = payload.view;
    if (payload.layers) {
      state.layers = payload.layers;
    }
  },
  updateLegendStateMutations(state, payload) {
    state.isLegendShow = payload;
  },
  updateXzqStateMutations(state, payload) {
    state.isShowXzq = payload;
  },
  updateAnalystToolStateMutations(state, payload) {
    state.isShowAnalystTool = payload;
  },
  updateTreeDataStateMutations(state, payload) {
    [...state.treeData] = payload;
  },
  updateLayersStateMutations(state, payload) {
    state.layers = payload;
  },
  updateInitLayersMutations(state, payload) {
    state.initLayers = payload;
  },
  updateUserServiceIdMutations(state, payload) {
    state.userServiceId = payload;
  },
  updateUserServicesMutations(state, payload) {
    state.userServices = payload;
  },
  updateSiderPanelMutations(state, payload) {
    state.siderPanel = payload;
  }
};

const actions = {
  updateMaps({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateMapsMutation", resdata);
  },
  updateLegendState({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateLegendStateMutations", resdata);
  },
  updateXzqState({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateXzqStateMutations", resdata);
  },
  updateAnalystToolState({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateAnalystToolStateMutations", resdata);
  },
  updateTreeDataState({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateTreeDataStateMutations", resdata);
  },
  updateLayersState({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateLayersStateMutations", resdata);
  },
  updateInitLayers({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateInitLayersMutations", resdata);
  },
  updateUserServiceId({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateUserServiceIdMutations", resdata);
  },
  updateUserServices({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateUserServicesMutations", resdata);
  },
  updateSiderPanel({
    state,
    commit,
    rootState
  }, resdata) {
    commit("updateSiderPanelMutations", resdata);
  },
};
export default {
  namespaced: true,
  state,
  mutations,
  actions
};